import axios from 'axios';
import * as actionTypes from './actionTypes';

export const getDetailInfo = (id) => {
  return (dispatch) => {
    axios.get('/api/detail.json?id=' + id).then((res) => {
      const result = res.data.data;
      dispatch(changeDetailData(result))
    })
  }
}

const changeDetailData = (result) => ({
  type: actionTypes.CHANGE_DETAIL_DATA,
  title: result.title,
  content: result.content
})